import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react'
import plugin from './plugin'
import myPlugin from './myPlugin'

// https://vitejs.dev/config/
const routes = [
  {
    path: "/",
    element: "@/layouts/index",
    children: [
      { path: "/page1", element: "@/pages/page1" },
      { path: "/page2", element: "@/pages/page1" },
    ],
  },
];
export default defineConfig({
  plugins: [react(),myPlugin(),plugin()],
  build:{
      rollupOptions: {
        output: {
          // manualChunks 配置
          manualChunks:(id)=>{
            if (id.includes('antd') || id.includes('@arco-design/web-react')) {
              return 'library';
            }
            if (id.includes('lodash')) {
              return 'lodash';
            }
            if (id.includes('react')) {
              return 'react';
            }
          
          }
          //  {
          //   // 将 React 相关库打包成单独的 chunk 中
          //   'react-vendor': ['react', 'react-dom','react-router-dom'],
          //   // 将 Lodash 库的代码单独打包
          //  // 'lodash': ['lodash-es'],
          //   // 将组件库的代码打包
          //   // 'library': ['antd', '@arco-design/web-react'],
          // },
        },
      }
  },
  resolve:{
    alias:{
      '@':'/src/',     
      "qps": "/src/.qps/exports.ts"
    }
  },
  server:{
    // watch:{
    //   ignored:['./src/routes.ts']
    // }
  }
})
